import config from "./config"
import api from './api'
import tool from './utils/tool'
import http from "./utils/request"
import { permission, rolePermission } from './utils/permission'

import scTable from './components/scTable'
import scTableColumn from './components/scTable/column.js'
import scFilterBar from './components/scFilterBar'
import scUpload from './components/scUpload'
import scUploadMultiple from './components/scUpload/multiple'
import scEditor from './components/scEditor'
import scUploadFile from './components/scUpload/file'
import scFormTable from './components/scFormTable'
import scTableSelect from './components/scTableSelect'
import scTableSelectInput from './components/scTableSelectInput' 
import scPageHeader from './components/scPageHeader'
import scSelect from './components/scSelect'
import scDialog from './components/scDialog'
import scForm from './components/scForm'
import scTitle from './components/scTitle'
import scWaterMark from './components/scWaterMark'
import scQrCode from './components/scQrCode'

import scBrandGoodsTypeChoice from './components/mysc/scBrandGoodsTypeChoice'
import scBrandGoodsChoice from './components/mysc/scBrandGoodsChoice'
import scBrandGoodsSelect from './components/mysc/scBrandGoodsSelect'
import scOrgSelect from './components/mysc/scOrgSelect'
import scOrgChoice from './components/mysc/scOrgChoice'
import scOrgListChoice from './components/mysc/scOrgListChoice'
import scGoodsSelect from './components/mysc/scGoodsSelect'
import scGoodsChoice from './components/mysc/scGoodsChoice'
import scGoodsPriceSelect from './components/mysc/scGoodsPriceSelect'
import scGoodsPriceChoice from './components/mysc/scGoodsPriceChoice'
import scUserInfoSelect from './components/mysc/scUserInfoSelect'
import scUserInfoChoice from './components/mysc/scUserInfoChoice'
import scSupplierSelect from './components/mysc/scSupplierSelect'
import scSupplierSelectInput from './components/mysc/scSupplierSelectInput'
import scMaterialSelect from './components/mysc/scMaterialSelect'
import scMaterialChoice from './components/mysc/scMaterialChoice'
import scEmptiesChoice from './components/mysc/scEmptiesChoice'
import scTaskOrderItemChoice from './components/mysc/scTaskOrderItemChoice'
import scAccountChoice from './components/mysc/scAccountChoice'
import scApplyOrderChoice from './components/mysc/scApplyOrderChoice'
import scBorrowPurchaseOrderChoice from './components/mysc/scBorrowPurchaseOrderChoice'
import scBorrowGoodsOrderChoice from './components/mysc/scBorrowGoodsOrderChoice'
import scApplyOrderSelect from './components/mysc/scApplyOrderSelect'
import scWarehouseSelect from './components/mysc/scWarehouseSelect'
import scWarehouseChoice from './components/mysc/scWarehouseChoice'
import scStoreSelect from './components/mysc/scStoreSelect'
import scStoreChoice from './components/mysc/scStoreChoice'
import scApplyOrgChoice from './components/mysc/scApplyOrgChoice'
import scApplyOrgSelect from './components/mysc/scApplyOrgSelect'
import scSupplierChoice from './components/mysc/scSupplierChoice'
import scPurchaseUnitySelect from './components/mysc/scPurchaseUnitySelect'
import scPurchaseUnityChoice from './components/mysc/scPurchaseUnityChoice'

import scTemplateSelect from './components/mysc/scTemplateSelect'
import scGoodsGroupChoice from './components/mysc/scGoodsGroupChoice'
import scFileImport from './components/scFileImport'
import scFileExport from './components/scFileExport'

import scStatusIndicator from './components/scMini/scStatusIndicator'
import scTrend from './components/scMini/scTrend'
import scTicketChoice from './components/mysc/scTicketChoice'
import scPointRuleChoice from './components/mysc/scPointRuleChoice'
import scSchemeRuleChoice from './components/mysc/scSchemeRuleChoice'
import scPosSaleOrderChoice from './components/mysc/scPosSaleOrderChoice'
import scExchangeRuleChoice from './components/mysc/scExchangeRuleChoice'
import scConsumeRuleChoice from './components/mysc/scConsumeRuleChoice'
import scPermissionGroupChoice from './components/mysc/scPermissionGroupChoice'

// 自定义公共组件 - 预览文件（图片、pdf、excel、word等）
import officeViewer from './components/officeViewer/officeViewer'
// 仅销售单打印组件
import salePrint from './components/salePrint/salePrint'
// 仅采购单打印组件
import purchasePrint from './components/purchasePrint/purchasePrint'
//配送费用打印组件
import deliveryFeePrint from './components/purchasePrint/deliveryFeePrint'
import applyDeliveryFeePrint from './components/salePrint/deliveryFeePrint' 

//押金费用打印组件
import applyDepositFeePrint from './components/salePrint/depositFeePrint' 
import depositFeePrint from './components/purchasePrint/depositFeePrint'

//自动完成搜索控件
import scAutoComplete from './components/mysc/scAutoComplete'
//导出
import scExport from './components/mysc/scExport'
//操作日志组件
import operateLogs from './components/operateOrderLog/operateLogs'

import auth from './directives/auth'
import role from './directives/role'
import time from './directives/time'
import copy from './directives/copy'
import errorHandler from './utils/errorHandler'

import * as elIcons from '@element-plus/icons-vue'
import * as scIcons from './assets/icons'

export default {
	install(app) {
		//挂载全局对象
		app.config.globalProperties.$CONFIG = config;
		app.config.globalProperties.$TOOL = tool;
		app.config.globalProperties.$HTTP = http;
		app.config.globalProperties.$API = api;
		app.config.globalProperties.$AUTH = permission;
		app.config.globalProperties.$ROLE = rolePermission;

		//注册全局组件
		app.component('scTable', scTable);
		app.component('scTableColumn', scTableColumn);
		app.component('scFilterBar', scFilterBar);
		app.component('scUpload', scUpload);
		app.component('scUploadMultiple', scUploadMultiple);
		app.component('scUploadFile', scUploadFile);
		app.component('scEditor', scEditor);
		app.component('scFormTable', scFormTable);
		app.component('scTableSelect', scTableSelect);
		app.component('scTableSelectInput', scTableSelectInput);
		app.component('scPageHeader', scPageHeader);
		app.component('scSelect', scSelect);
		app.component('scDialog', scDialog);
		app.component('scForm', scForm);
		app.component('scTitle', scTitle);
		app.component('scWaterMark', scWaterMark);
		app.component('scQrCode', scQrCode);
		app.component('scStatusIndicator', scStatusIndicator);
		app.component('scTrend', scTrend);


		app.component('scBrandGoodsTypeChoice', scBrandGoodsTypeChoice);
		app.component('scBrandGoodsChoice', scBrandGoodsChoice);
		app.component('scBrandGoodsSelect', scBrandGoodsSelect);

		app.component('scOrgSelect', scOrgSelect);
		app.component('scOrgChoice', scOrgChoice);
		app.component('scOrgListChoice', scOrgListChoice);

		app.component('scGoodsSelect', scGoodsSelect);
		app.component('scGoodsChoice', scGoodsChoice);
		app.component('scGoodsPriceSelect', scGoodsPriceSelect);
		app.component('scGoodsPriceChoice', scGoodsPriceChoice);
		app.component('scUserInfoSelect', scUserInfoSelect);
		app.component('scUserInfoChoice', scUserInfoChoice);
		app.component('scSupplierSelect', scSupplierSelect);
		app.component('scSupplierSelectInput', scSupplierSelectInput);
		app.component('scMaterialSelect', scMaterialSelect);
		app.component('scEmptiesChoice', scEmptiesChoice);
		app.component('scMaterialChoice', scMaterialChoice);
		app.component('scTaskOrderItemChoice', scTaskOrderItemChoice);
		app.component('scAccountChoice', scAccountChoice);
		app.component('scApplyOrderChoice', scApplyOrderChoice);
		app.component('scApplyOrderSelect', scApplyOrderSelect);
		app.component('scBorrowPurchaseOrderChoice', scBorrowPurchaseOrderChoice);
		app.component('scBorrowGoodsOrderChoice', scBorrowGoodsOrderChoice);
		app.component('scWarehouseSelect', scWarehouseSelect);
		app.component('scWarehouseChoice', scWarehouseChoice);
		app.component('scStoreSelect', scStoreSelect);
		app.component('scStoreChoice', scStoreChoice);
		app.component('scApplyOrgChoice', scApplyOrgChoice);
		app.component('scApplyOrgSelect', scApplyOrgSelect);
		app.component('scSupplierChoice', scSupplierChoice);
		app.component('scPurchaseUnitySelect', scPurchaseUnitySelect);
		app.component('scPurchaseUnityChoice', scPurchaseUnityChoice);
		app.component('scTemplateSelect', scTemplateSelect);
		app.component('scGoodsGroupChoice', scGoodsGroupChoice);
		app.component('scTicketChoice',scTicketChoice);
        app.component('scFileImport',scFileImport);
		app.component('scFileExport',scFileExport);
		app.component('scPointRuleChoice',scPointRuleChoice);
		app.component('scSchemeRuleChoice',scSchemeRuleChoice);
		app.component('scPosSaleOrderChoice',scPosSaleOrderChoice);
		app.component('scExchangeRuleChoice',scExchangeRuleChoice);
		app.component('scConsumeRuleChoice',scConsumeRuleChoice);
		app.component('scPermissionGroupChoice',scPermissionGroupChoice);

		app.component('officeViewer', officeViewer);
		app.component('salePrint', salePrint);
		app.component('purchasePrint', purchasePrint);
		app.component('deliveryFeePrint', deliveryFeePrint);
		app.component('applyDeliveryFeePrint', applyDeliveryFeePrint);
		app.component('applyDepositFeePrint', applyDepositFeePrint);
		app.component('depositFeePrint', depositFeePrint);
		app.component('operateLogs', operateLogs);
		app.component('scAutoComplete', scAutoComplete);
		app.component('scExport', scExport);
		
		//注册全局指令
		app.directive('auth', auth)
		app.directive('role', role)
		app.directive('time', time)
		app.directive('copy', copy)

		//统一注册el-icon图标
		for(let icon in elIcons){
			app.component(`ElIcon${icon}`, elIcons[icon])
		}
		//统一注册sc-icon图标
		for(let icon in scIcons){
			app.component(`ScIcon${icon}`, scIcons[icon])
		}

		//关闭async-validator全局控制台警告
		window.ASYNC_VALIDATOR_NO_WARNING = 1

		//全局代码错误捕捉
		app.config.errorHandler = errorHandler
	}
}
